import Vue from 'vue'
import Router from 'vue-router'
import Index from './../home/index';
import Wallet from './../home/wallet';
import UserCenter from './../home/userCenter';
import Login from '../user/login';

import RollOut from './../wallet/rollOut';
import ShiftTo from './../wallet/shiftTo';
import ChangeCard from './../wallet/changeCard';
import ChangePassword from './../wallet/changePassword';
import CloseAccount from '../wallet/closeAccount';
import OpenAccount from './../wallet/openAccount';
import Argument from './../wallet/argument';
import Rooibos from './../wallet/rooibos';
import WxTransfer from './../user/wxTransfer';

import Feedback from './../service/feedback';

import VenueList from './../venue/venueList';
import VenueDetail from './../venue/venueDetail';

Vue.use(Router);
const router = new Router({
  routes: [
      { path: '' , name: 'index' , component: Index , meta: { keepAlive: true} },
      { path: '/wallet' , name: 'wallet' ,component: Wallet , meta: { keepAlive: true}},
      { path: '/userCenter' , name: 'userCenter' , component: UserCenter , meta: { keepAlive: true}},
      { path: '/rollOut' , name: 'rollOut' , component: RollOut },
      { path: '/shiftTo' , name: 'shiftTo' , component: ShiftTo },
      { path: '/changeCard' , name: 'changeCard' , component: ChangeCard },
      { path: '/changePassword' , name: 'changePassword' , component: ChangePassword },
      { path: '/closeAccount' , name: 'closeAccount' , component: CloseAccount },
      { path: '/openAccount' , name: 'openAccount' , component: OpenAccount },
      { path: '/argument' , name: 'argument' , component: Argument },
      { path: '/rooibos' , name: 'rooibos' , component: Rooibos },
      { path: '/login' , name: 'login' , component: Login},
      { path: '/wxTransfer' , name: 'wxTransfer' , component: WxTransfer},
      { path: '/feedback' , name: 'feedback' , component: Feedback},
      { path: '/venueList' , name: 'venueList' , component: VenueList},
      { path: '/venueDetail' , name: 'venueDetail' , component: VenueDetail}
  ]
});

router.beforeEach((to , from , next)=>{
    next();
    if(window.feiyu){
        if(to.name == 'userCenter'){
            window.feiyu.changeStatusBarWithDic(JSON.stringify({
                red: 31,
                green: 117,
                blue: 252,
                hasColor: 'yes'
            }));
        }else{
            window.feiyu.changeStatusBarWithDic(JSON.stringify({
                red: 255,
                green: 255,
                blue: 255,
                hasColor: 'no'
            }));
        }
    }
});

export default  router;
